package com.upcode.weighing.detect.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.upcode.weighing.detect.service.DetectRecordService;
import com.upcode.weighing.domain.DetectRecord;
import com.upcode.weighing.mapper.DetectRecordMapper;
import com.upcode.weighing.vo.req.DetectRecordQueryParam;
import com.upcode.weighing.vo.req.PageReqVo;
import com.upcode.weighing.vo.resp.DetectRecordRespVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author alex
 * @since 2024-07-21
 */
@Service
public class DetectRecordServiceImpl extends ServiceImpl<DetectRecordMapper, DetectRecord> implements DetectRecordService {
    @Autowired
    private DetectRecordMapper detectRecordMapper;

    @Override
    public IPage<DetectRecordRespVo> queryPageList(PageReqVo<DetectRecordQueryParam> vo) {
        long currentPage = vo.getPage().getCurrentPage();
        long pageSize = vo.getPage().getPageSize();
        Page page = new Page(currentPage, pageSize);
        IPage<DetectRecordRespVo> iPage = detectRecordMapper.selectPageList(page, vo.getParams());
        return iPage;
    }

    @Override
    public List<DetectRecordRespVo> queryTopN(Integer num) {
        return detectRecordMapper.queryTopN(num);
    }

    @Override
    public IPage<DetectRecordRespVo> queryOverPage(PageReqVo<DetectRecordQueryParam> vo) {
        long currentPage = vo.getPage().getCurrentPage();
        long pageSize = vo.getPage().getPageSize();
        Page page = new Page(currentPage, pageSize);
        IPage<DetectRecordRespVo> iPage = detectRecordMapper.selectOverPageList(page, vo.getParams());
        return iPage;
    }

}
